<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台管理</title>

    <script src="__STATIC__/jquery-2.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

    {include file="public/header" /}
    {include file="public/left" /}
    <style>
        .layui-table-cell{
            height: 33px;
        }
    </style>



    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <fieldset class="layui-elem-field layui-field-title"  style="margin-top: 50px;">
                <legend>血糖监测</legend>
            </fieldset>

            <form class="layui-form" action="">





                <div class="layui-form-item">


                    <!--<div class="layui-inline">
                        <label class="layui-form-label">用户id</label>
                        <div class="layui-input-inline">
                            <input type="text" name="uid" id="uid" class="layui-input">
                        </div>
                    </div>-->

                    <div class="layui-inline">
                        <label class="layui-form-label">用户名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="username" id="username" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">日期</label>
                        <div class="layui-input-inline">
                            <input type="text" name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">时间段</label>
                        <div class="layui-input-inline">
                            <select name="itemid" id="itemid">

                                <option value=""></option>
                                {volist name="itemlist" id="it"}
                                     <option value="{$it.itemid}">{$it.itemname}</option>
                                {/volist}

                            </select>
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label">健康情况</label>
                        <div class="layui-input-inline">
                            <select name="health" id="health" >
                                <option value=""></option>
                                <option value="1">健康</option>
                                <option value="2">低血糖</option>
                                <option value="3">超低血糖</option>
                                <option value="4">高血糖</option>
                                <option value="5">超高血糖</option>
                            </select>
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label">血糖情况</label>
                        <div class="layui-input-inline">
                            <select name="type" id="type" >
                                <option value=""></option>
                                <option value="1">低血糖</option>
                                <option value="2">高血糖</option>
                                <option value="3">正常</option>
                            </select>
                        </div>
                    </div>


                    <button class="layui-btn" id="searchbtn" data-type="reload">搜索</button>
                </div>

            </form>
    <div style="clear: both;"></div>

            <table class="layui-hide" id="list"></table>



            <script>
                layui.use('table', function(){
                    var table = layui.table;

                    table.render({
                        elem: '#list'

                        ,url: "{:url('treat/bloodlistjson')}"
                        ,cols: [[
                            {type:'checkbox',width:'2%'}
                            ,{field:'cid', width:'5%', title: 'ID', sort: true}
                            ,{field:'date', width:'15%', title: '日期'}
                            ,{field:'username', width:'15%', title: '用户名'}
                            ,{field:'itemname', width:'15%', title: '时间段'}
                            ,{field:'value', width:'10%', title: '血糖值(mmol/L)'}
                            ,{field:'health', width: '10%', title: '健康情况' }
                            ,{field:'type', width:'10%', title: '血糖情况'}
                            ,{field:'operation', width:'18%', title: '操作',templet: '#operation'}
                        ]]
                        ,page: true
                        ,id:'tb'
                    });

                    var $ = layui.$, active = {
                        reload: function(){
                            var username = $('#username');
                            var date = $('#date');
                            var itemid = $('#itemid');
                            var health = $('#health');
                            var type = $('#type');

                            //执行重载
                            table.reload('tb', {
                                page: {
                                    curr: 1 //重新从第 1 页开始
                                }
                                ,where: {
                                    key: {
                                        username: username.val(),
                                        date: date.val(),
                                        itemid: itemid.val(),
                                        health: health.val(),
                                        type: type.val()

                                    }
                                }
                            });
                        }
                    };

                    $('#searchbtn').on('click', function(e){
                        e.preventDefault();

                        var type = $(this).data('type');

                        active[type] ? active[type].call(this) : '';
//                        alert();
                    });


                });
            </script>
            <script type="text/html" id="operation">
                <a class="layui-btn layui-btn-normal" href="{:url('treat/blooddetail' )}?{literal}cid={{d.cid}} {/literal}" >详细</a>
                <a class="layui-btn layui-btn-danger delbtn"  onclick=" return confirm('你真的要删除这个记录吗')" href="{:url('treat/checkdelete' )}?{literal}cid={{d.cid}} {/literal}" >删除</a>
            </script>
        </div>
    </div>


</div>

<script>

    //JavaScript代码区域
    layui.use('laydate', function(){

        var laydate = layui.laydate;

        //常规用法
        laydate.render({
            elem: '#date'
        });


    });
    $('#logout').click(function (e) {
        e.preventDefault();
        layui.use('layer', function(){
            var layer = layui.layer;

            layer.confirm('你真的要退出吗？',['yes','no'],function () {
                location.href="{:url('login/logout')}";
            },function () {
                
            })
        });
    })





</script>

</body>
</html>